package com.it2297.renderer;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.table.TableCellRenderer;

import java.awt.Color;
import java.awt.Component;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;


import com.it2297.model.Job;
import com.it2297.model.Product;

public class ApplicationCellRenderer extends JLabel implements TableCellRenderer {

	private Job job;
	
	/**
	 * Create the panel.
	 */
	public ApplicationCellRenderer() {
		setOpaque(true);
		setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
		setVerticalTextPosition(JLabel.TOP);
		setIconTextGap(10);
	}

	public Component getTableCellRendererComponent(JTable table, Object object, boolean isSelected, boolean hasFocus, int row, int column) {
		job = (Job) object;
		
		switch(column){
		case 0:
			setIcon(null);
			setText("<html><ul><u>Job Details:</u> <li>Job Title: " + job.getTitle() + "</li><li>Job ID: " + job.getJobId() +"</li><li> Company Name: " + job.getCompanyName() + "</li></ul></html>");
			break;
			
		case 1:
			setIcon(null);
			setText("<html><ul><u>Application details:</u> <li> Application Status: " + job.getApplicationStatus() + 
					"</li><li>Date Of Application: " + job.getDate()+"</li></ul></html>");
			break;
		}
		
	
		
		if(row % 2 ==0){
			//setBackground(Color.WHITE);
			setBackground(new Color(240, 240, 240));
		}else{
			//setBackground(new Color(240, 240, 240));
			  setBackground(new Color(176,196,222));
			  
		}
		
		setForeground(Color.BLACK);
		
		if(isSelected){
			setForeground(new Color(255,255,255));
			setBackground(new Color(80,80,80));
		}
		
		return this;
	}

}
